package cn.autoOffice.controller;
/*
 *功能说明：考勤控制层
 *@author 皮永浪
 *@Date 2023/3/29 10:58
 */

import cn.autoOffice.bean.pojo.Check;
import cn.autoOffice.bean.vo.Result;
import cn.autoOffice.service.CheckService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("check")
public class CheckController {

    @Autowired
    private CheckService checkService;

    //查询所有的考勤信息
    @PostMapping("allCheck/{pageNo}/{pageSize}")
    public Result<PageInfo<Check>> getAllCheck(@PathVariable Integer pageNo, @PathVariable Integer pageSize){
        PageHelper.startPage(pageNo,pageSize);
        List<Check> checks = checkService.findAllChecks();
        PageInfo pageInfo = new PageInfo(checks);
        System.out.println("====" + pageInfo.getTotal());
        return Result.success(pageInfo);
    }

    //添加考勤信息
    @PostMapping("addCheck")
    @ResponseBody
    public String addCheckInfo(Check check){
        boolean i = checkService.addCheckInfo(check);
        if (i){
            return "0005:打卡成功";
        }else {
            return "0006:打卡失败";
        }
    }
}
